﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Corona.TagToolkit
{


    public class Pair<TA, TB>
    {
        TA tA;
        TB tB;
        public Pair(TA a, TB b)
        {
            tA = a; tB = b;
        }

        public Pair() { }

        public TA A
        {
            get { return tA; }
            set { tA = value; }
        }

        public TB B
        {
            get { return tB; }
            set { tB = value; }
        }

        public static implicit operator Corona.TagContract.Pair<TA, TB>(Corona.TagToolkit.Pair<TA, TB> pair)
        {
            Corona.TagContract.Pair<TA, TB> p = new Corona.TagContract.Pair<TA, TB>();
            p.A = pair.tA;
            p.B = pair.tB;
            return p;
        }
        /// <summary>
        /// 已重载，两个值值相等
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            Pair<TA, TB> pair = obj as Pair<TA, TB>;
            if (pair == null)
                return false;
            else
                return this.A.Equals(pair.A) && this.B.Equals(pair.B);
        }
        public override int GetHashCode()
        {
            return this.A.GetHashCode() ^ this.B.GetHashCode();
        }

        public override string ToString()
        {
            return "A = \"" + A + "\",B = \"" + B + "\"";
        }
    }
}